package customview.ike.com.customviewproject.widget.Refresh1.rotationArrow;

import android.content.Context;
import android.media.Image;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.ImageView;

import customview.ike.com.customviewproject.widget.Refresh1.PullAbleView;
import customview.ike.com.customviewproject.widget.Refresh1.PullToRefreshLayout;

/**
 * Created by Administrator on 2017/11/28.
 */

public class PullAbleImageView extends android.support.v7.widget.AppCompatTextView implements PullAbleView{
    private String Tag="PullAbleImageView";
    private PullToRefreshLayout parent;

    public PullAbleImageView(Context context) {
        super(context);
    }

    public PullAbleImageView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public PullAbleImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    //没有滑动布局的判断方法
    @Override
    public boolean canPullDown() {
        if (getParent() instanceof PullToRefreshLayout){
            parent = (PullToRefreshLayout) getParent();
        }
        if (parent!=null){
           if ( parent.getScrollY()==0&&parent.getScrollDirection()== PullToRefreshLayout.ScrollDirection.DOWN){
               return true; 
           }
        }
        return false;
       
        
    }

    @Override
    public boolean canPullUp() {
        if (getParent() instanceof PullToRefreshLayout){
            parent = (PullToRefreshLayout) getParent();
        }
        if (parent!=null){
            if ( parent.getScrollY()==0&&parent.getScrollDirection()== PullToRefreshLayout.ScrollDirection.UP){
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return true;
    }
}

